import {Component, OnInit, Input, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
import {Router, ActivatedRoute} from "@angular/router";
// import {CrowdBaseBeanH5VO} from "@interface/crowd.model";
import {SharedService} from "@shared/service/shared/shared.service";
import {ImageServeService} from "@shared/service/image/image-serve.service.ts";
import {CrowdBaseBeanH5VO} from "@interface/index";



@Component({
  selector: 'seed-crowd-card',
  templateUrl: './crowd-card.component.html',
  styleUrls: ['./crowd-card.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class CrowdCardComponent implements OnInit {
  @Input() crowdList: CrowdBaseBeanH5VO;
  @Input() myCrowd: any;

  @Input()
  set url(url: string) {
    this._StateUrl = this.imgService.getCrowdStateImg(url);
  }

  get url() {
    return this._StateUrl;
  }

  /*
   * 0,草稿,1,待审核(crowd_pending) 2,审核未通过(crowd_not_pass) 3,众筹中(crowding)，
   * 4，众筹成功(crowd_completed) 5，众筹失败(crowd_defeated),6已下架(crowd_colded_out) 7已禁用 ,
   * */

  public statusPicture = ['draft', 'pending', 'notPass', 'crowding', 'completed', 'defeated', 'coldOut'];
  public _StateUrl: string;
  public progress: any;

  constructor(public router: Router,
              public route: ActivatedRoute,
              private imgService: ImageServeService) {

  }

  ngOnInit() {

  }

  /*
   *@跳转个人主页 auth:baoww765
   */
  goToHomepage(userId) {
    this.router.navigate(['/', userId]);
  }

  /*
   *@跳转订单详情页 auth:baoww765
   */
  goToCrowdDetail(crowdCode) {
    this.router.navigate(['/crowd/crowd-details'], {queryParams: {crowdCode: crowdCode}});
  }

}
